<?php

namespace app\admin\model;

use think\Model;


class LookResource extends Model
{

    

    

    // 表名
    protected $name = 'look_resource';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
            'create_time_text'
    ];

    public function getFileAttr($value,$data){
        if(empty($value)){
            return '';
        }
        return cdnurl($value,true);
    }

    public function getCreateTimeTextAttr($value,$data)
    {
        return date('Y-m-d H:i',$data['create_time']);
    }
    public function look()
    {
        return $this->belongsTo('Look', 'look_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
